// 第一个部署
// 1、SR、SSR、UR 限制了发行数量 (部署时完成)
// 2、需要设置一个minter, bindBox 盲盒合约，用于开盲盒后铸造 (部署后完成) setMinter 方法
// gas:  0.06BNB
// address: 0x025E2F9FfafA019E4aA42234fdE4DDaFBFC096dE
const { BigNumber } = require('ethers');

async function main() {

    //1、部署NFTDog
    const nftName = "testDog";
    const nftSymbol = "TDog";
    const nftUrl = "https://nftswap-hm.oss-cn-chengdu.aliyuncs.com/metadata/";
    const SRtotalSupply = 6000;
    const SSRTotalSupply = 3000;
    const URTotalSupply = 1000;

    const nftStruggleDog = await ethers.getContractFactory("StruggleDog");
    const instanceNftStruggleDog = await nftStruggleDog.deploy(SRtotalSupply,SSRTotalSupply, URTotalSupply, nftName, nftSymbol, nftUrl);
    await instanceNftStruggleDog.deployed();
    console.log("NftStruggleDog deployed to:", instanceNftStruggleDog.address);

    //2、部署彩票合约
    const SR = {weightsName: "SR", enumId: 1, issued: 0, totalSupply:6000};
    const SSR = {weightsName: "SSR", enumId: 2, issued: 0, totalSupply:3000};
    const UR = {weightsName: "UR", enumId: 3, issued: 0, totalSupply:1000};
    const token_limit = 10000;  //NFT 发行数量

    const Lottery = await ethers.getContractFactory("Lottery");
    const instanceLottery = await upgrades.deployProxy(Lottery, [token_limit,[1,2,3],[SR,SSR,UR]], {initializer:'__Lottery_init'});
    await instanceLottery.deployed();
    console.log("Lottery deployed to:", instanceLottery.address);

    //3、部署质押合约
    const feeToken = "0x55d398326f99059fF775485246999027B3197955"; // 支付token BRC20-USDT 地址
    const _pledgeNFTcontarct = instanceNftStruggleDog.address; // 奋斗狗NFT合约 地址
    const NFTSwapAddress = "0xba58F107fD3e82D014BEed3Ca8D82f4c77a333bE"; // NFTSWAP 合约地址
    const rarities = [1,2,3]; // 稀有度枚举
    const lpAmounts = [1,2,3]; // 稀有度份额

    const LpToken = await ethers.getContractFactory("LpToken");
    const instance = await upgrades.deployProxy(LpToken, [feeToken,_pledgeNFTcontarct,NFTSwapAddress,rarities, lpAmounts], {initializer:'__LpToken_init'});
    await instance.deployed();
    console.log("pledge deployed to:", instance.address);
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error);
        process.exit(1);
    });
